home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 25 / CU Amiga Magazine's Super CD-ROM 25 (1998)(EMAP Images)(GB)(Track 1 of 2)[!][issue 1998-08].iso / CUCD / WWW / http / www.cu-amiga.co.uk / features / c-tutorial / Part-6.lzx / Part-6 / asl2 / menu.c < prev    next >
C/C++ Source or Header  |  1984-05-19  |  2KB  |  80 lines

  1. #include "menu.h"
  2. #include "visual.h"
  3.  
  4. #include<libraries/gadtools.h>
  5.  
  6. #include<stdio.h>
  7.  
  8. #include<clib/gadtools_protos.h>
  9. #include<clib/intuition_protos.h>
  10.  
  11. /* Global record of our menu strip */
  12. static struct Menu* menu = NULL;
  13.  
  14. /* Unset menu check mark */
  15. void uncheckToolBar(struct Window* win)
  16. {
  17.     struct MenuItem* item;
  18.     /* First, remove menu strip from window */
  19.     ClearMenuStrip(win);
  20.     /* 2,1 is Tool Bar item (see below) */
  21.     item = ItemAddress(menu, FULLMENUNUM(2,1,0));
  22.     /* Unset CHECKED flag */
  23.     item->Flags &= ~CHECKED;
  24.     /* Reattach menu strip to window */
  25.     ResetMenuStrip(win,menu);
  26. }
  27.  
  28. /* Create the menu strip, using GadTools menu functions */
  29. int createMenuStrip()
  30. {
  31.     /* The description of our menus */
  32.     struct NewMenu mymenu[] =
  33.     {
  34.         { NM_TITLE, "Project",            0,        0, 0, 0,},
  35.         {  NM_ITEM,        "Load",                "L",    0, 0, 0,},
  36.         {  NM_ITEM,        "Save",                "S",    0, 0, 0,},
  37.         {  NM_ITEM,        NM_BARLABEL,    0,        0, 0, 0,},
  38.         {  NM_ITEM,        "Quit",                "Q",    0, 0, 0,},
  39.         { NM_TITLE, "Pen",                    0,        0, 0, 0,},
  40.         {  NM_ITEM,        "Next",                "N",    0, 0, 0,},
  41.         {  NM_ITEM,        "Prev",                "P",    0, 0, 0,},
  42.         {  NM_ITEM,        NM_BARLABEL,    0,        0, 0, 0,},
  43.         {  NM_ITEM,        "Reset",            "R",    0, 0, 0,},
  44.         { NM_TITLE, "Tools",                0,        0, 0, 0,},
  45.         {  NM_ITEM,        "Screen Bar",    "C",    CHECKIT | MENUTOGGLE | CHECKED, 0, 0,},
  46.         /* Next item is index (2,1,0), see uncheckToolBar() above */
  47.         {  NM_ITEM,        "Tool Bar",        "T",    CHECKIT | MENUTOGGLE | CHECKED, 0, 0,},
  48.         {   NM_END, NULL,                        0,        0, 0, 0,},
  49.     };
  50.     if (menu = CreateMenus(mymenu, TAG_END))
  51.     {
  52.         APTR vinfo = getVisual();
  53.         if (LayoutMenus(menu, vinfo, TAG_END))
  54.             /* Succeeded */
  55.             return TRUE;
  56.         else
  57.             printf("Error: could not layout menus\n");
  58.     }
  59.     else
  60.         printf("Error: could not create menu strip\n");
  61.     /* Failed */
  62.     return FALSE;
  63. }
  64.  
  65. void freeMenuStrip()
  66. {
  67.     if(menu)
  68.     {
  69.         FreeMenus(menu);
  70.         /* Set to NULL to indicate that it's been freed */
  71.         menu = NULL;
  72.     }
  73. }
  74.  
  75. /* Give access to the private menu */
  76. struct Menu* getMenuStrip()
  77. {
  78.     return menu;
  79. }
  80.